import numpy as np
from tqdm import tqdm

file = "demo.npy"
output = "demo02.npy"

a = np.load(file, allow_pickle=True)

temp = a[0].flatten()
for i in tqdm(range(a.shape[0]-1)):
    temp = np.concatenate((temp, a[i+1].flatten()))
np.save(output,temp)
print(np.load(output, allow_pickle=True)[:100])



# x_axis = [0]
# a = 10
# for i in range(10):
#     a = a / 10
#     x_axis.extend([a,-a])
# x_axis = sorted(x_axis)

# # print(x_axis)

# lists = [[] for i in range(len(x_axis)+1)]

# for num in tqdm(data):
#     for index in range(len(x_axis)):
#         if num <= x_axis[index]:
#             lists[index].append(num)
#             break
#         elif index==len(x_axis):
#             lists[-1].append(num)

# np.save("process.npy", lists)


# for i in range(len(lists)):
#     print(len(lists[i])/len(data))

# import numpy as np
# import collections
# import math
# import matplotlib.pyplot as plt

# from tqdm import tqdm
# from multiprocessing import Pool

# def log10_pos_neg(x):
#     if x > 0:
#         return int(math.log10(x))
#     elif x == 0:
#         return 0
#     else:
#         return -int(math.log10(-x))


# if __name__ == '__main__':
#     data = np.load("demo2.npy", allow_pickle=True)
#     data = data[:1000]
#     data_processed = None

#     with Pool(processes=8) as pool:
#         data_processed = list(tqdm(pool.imap_unordered(log10_pos_neg, data), total=25163840))

#     a = np.array(data_processed)

#     np.save('log10.npy',a)
#     # np.count_nonzero(a)
#     result = collections.Counter(a)

#     plt.bar(result.keys(), result.values())
#     plt.show()
#     print("")

# a = np.load("demo.npy", allow_pickle=True)[:5]
# print(a[0].shape)
